#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n , m;
int a[N];
int main(){
    cin >> n >> m;

    for(int i = 1; i<= n; i++)cin >> a[i];
      
    sort(a+1,a+1+n);
    map<int, int> mp;
    for(int i = 1; i<= n; i++){
        mp[a[i]]++;
    }
    int t = n - m,res = 0;
    for(auto & x: mp){
        if(t <= 0)break;
        res = max(res,x.second);
        t -= x.second;
    }
      res = min(m,res);
    cout << res;
    return 0;
}


// 补题 （不用排序，可以直接进行遍历，map的遍历是由小到大）
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n , m;
int a[N];
int main(){
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 1; i<= n; i++){
        cin >> a[i];
         mp[a[i]]++;
    }
   
    int t = n ,res = 0;
    for(auto & x: mp){
        if( t >= m){
            res = max(res,min(x.second,m));
        }
        t -= x.second;
    }
    cout << res;
    return 0;
}